﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ERP_CustomerReturnManager.aspx.cs" Inherits="CRM_Store_ERP_CustomerReturnManager" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>客户退货单</title>
    <link href="../css/PageStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .x-grid3-hd-inner {
            text-align: center;
            position: relative;
            cursor: inherit;
            padding: 4px 3px 4px 5px;
        }


    </style>
    <script type="text/javascript" src="../JavaScript/Common.js"></script>
    <script type="text/javascript" >
        function DoDelete() {
            if (!gridPanel_listdata.hasSelection()) {
                Ext.Msg.alert("提示", "请选择记录!");
                return;
            }
            Ext.Msg.confirm("确认框", "是否确认删除？", function (btn) {
                if (btn == "yes") {
                    var record = gridPanel_listdata.selModel.getSelected();
                    Ext.net.DirectMethods.DeleteModel(record.data.CustomerReturnId);
                }
            });
        }

        function StateRenderer(value) {
            if (value == 0) {
                return "<font color='#E0861A' >未提交</font>";
            } else if (value == 1) {
                return "<font color='#6FA8DC' >已提交</font>";
            } else if (value == 2) {
                return "<font color='green' >已审核</font>";
            } 
            return value;
        }

        function Onextcomb_Supplier_BeforeSelect() {
            if (extcomb_CustomerId.mimicing == false)
                return false;
        }
        function SearchOperate() {
            Store_Customer.reload();
        }
        function SearchOperate2() {
            if (extcomb_CustomerId.text == "") {
                Store_Customer.reload();
            }
        }
    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled" />
    <form id="form1" runat="server">
    <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout" >
        <Content>
            <ext:Panel runat="server" Border="false" Layout="RowLayout">
                <TopBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button ID="extBtn_Refresh" runat="server" Text="刷新" Icon="ArrowRefresh">
                                <Listeners>
                                    <Click Handler="gridPanel_listdata.reload();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="extBtn_Add" runat="server" Text="新增" Icon="Add" />
                            <ext:Button ID="extBtn_Edit" runat="server" Text="修改" Icon="GroupEdit" />
                            <ext:Button ID="extBtn_Delete" runat="server" Text="删除" Icon="Delete">
                                <Listeners>
                                    <Click Fn="DoDelete" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:FormPanel ID="searchForm" runat="server" Border="false" Padding="5" Height="97">
                        <Content>
                            <ext:FieldSet runat="server" Title="查询条件" Border="true" Layout="ColumnLayout" Header="true" Height="84">
                                <Items>
                                    <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                        <Items>
                                            <ext:TextField runat="server" ID="exttxtf_CustomerReturnNo" FieldLabel="收退单号" AnchorHorizontal="0.95" />
                                            <ext:ComboBox runat="server" ID="extcomb_CustomerId" AllowBlank="false" FieldLabel="客户"
                                                DisplayField="CustomerName" ValueField="CustomerId" TypeAhead="false" LoadingText="Searching..."
                                                TriggerAction="All" ForceSelection="false" SelectOnFocus="true" EmptyText="请输入汉字或拼音简码"
                                                Mode="Remote" ItemSelector="div.search-item" MinChars="1" ListWidth="600" TabIndex="10"
                                                AnchorHorizontal="0.95" PageSize="10" >
                                                <Template ID="Template1" runat="server">
                                                    <Html>
                                                    <table width="100%" style="background-color: #f0f0f0; font-size: small; font-weight: bold">
                                                        <tr>
                                                            <td style="width: 33%;">客户</td>
                                                            <td style="width: 33%;">拼音码</td>
                                                            <td style="width: 33%;">地址</td>
                                                        </tr>
                                                    </table>
                                                    <tpl for=".">
                                                        <div class="search-item">
                                                            <table width="100%">
                                                                <tr>
                                                                    <td style="width:33%; ">{CustomerName}</td>
                                                                    <td style="width:33%; ">{Spell}</td>
                                                                    <td style="width:33%; ">{Address}</td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </tpl>
                                                    </Html>
                                                </Template>
                                                <Listeners>
                                                    <Change Fn="SearchOperate" />
                                                    <KeyDown Fn="SearchOperate2" />
                                                    <Expand Fn="SearchOperate" />
                                                    <BeforeSelect Fn="Onextcomb_Supplier_BeforeSelect" />
                                                </Listeners>
                                                <Store>
                                                    <ext:Store runat="server" ID="Store_Customer" OnRefreshData="StoreCustomer_Refresh" RemotePaging="true">
                                                        <Reader>
                                                            <ext:JsonReader IDProperty="CustomerId">
                                                                <Fields>
                                                                    <ext:RecordField Name="CustomerId" />
                                                                    <ext:RecordField Name="CustomerName" />
                                                                    <ext:RecordField Name="Spell" />
                                                                    <ext:RecordField Name="Address" />
                                                                </Fields>
                                                            </ext:JsonReader>
                                                        </Reader>
                                                    </ext:Store>
                                                </Store>
                                            </ext:ComboBox>
                                        </Items>
                                    </ext:Container>
                                    <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                        <Items>
                                            <ext:ComboBox ID="extcomb_STOREROOM_ID" runat="server" FieldLabel="收退库房"
                                                AnchorHorizontal="0.95" Editable="false" ValueField="STOREROOM_ID" DisplayField="STOREROOM_NAME"
                                                TabIndex="2">
                                                <Store>
                                                    <ext:Store ID="Store_Rome" runat="server">
                                                        <Reader>
                                                            <ext:JsonReader IDProperty="STOREROOM_ID">
                                                                <Fields>
                                                                    <ext:RecordField Name="STOREROOM_ID" />
                                                                    <ext:RecordField Name="STOREROOM_NAME" />
                                                                </Fields>
                                                            </ext:JsonReader>
                                                        </Reader>
                                                    </ext:Store>
                                                </Store>
                                            </ext:ComboBox>
                                            <ext:CompositeField ID="CompositeField1" runat="server" AnchorHorizontal="0.95" FieldLabel="创建时间">
                                                <Items>
                                                    <ext:DateField ID="extdate_start" Vtype="daterange" runat="server" Flex="1" TabIndex="4">
                                                        <Listeners>
                                                            <Render Handler="this.endDateField = '#{extdate_end}'" />
                                                        </Listeners>
                                                    </ext:DateField>
                                                    <ext:Label ID="Label1" runat="server" Text="到" StyleSpec=" padding-top:3px;">
                                                    </ext:Label>
                                                    <ext:DateField ID="extdate_end" Vtype="daterange" runat="server" Flex="1" TabIndex="5">
                                                        <Listeners>
                                                            <Render Handler="this.startDateField = '#{extdate_start}'" />
                                                        </Listeners>
                                                    </ext:DateField>
                                                </Items>
                                            </ext:CompositeField>
                                        </Items>
                                    </ext:Container>
                                    <ext:Container runat="server" Layout="FormLayout" LabelAlign="Right" ColumnWidth="0.33">
                                        <Items>
                                            <ext:ComboBox ID="extcomb_State" runat="server" Editable="false" FieldLabel="状态" AnchorHorizontal="0.95" SelectedIndex="0" >
                                                <Items>
                                                    <ext:ListItem Text="全部" Value="-1" />
                                                    <ext:ListItem Text="未提交" Value="0" />
                                                    <ext:ListItem Text="已提交" Value="1" />
                                                    <ext:ListItem Text="已审核" Value="2" />
                                                </Items>
                                            </ext:ComboBox>
                                            <ext:Container ID="Container1" runat="server" Layout="ColumnLayout">
                                                <Items>
                                                    <ext:Panel ID="Panel2" runat="server" Height="25" AnchorHorizontal="0.95" Border="false" ButtonAlign="Right">
                                                        <Content>
                                                            <table width="100%">
                                                                <tr style="width: 100%">
                                                                    <td align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                    </td>
                                                                    <td align="right" width="50%">
                                                                        <ext:Button ID="extBtn_Search" runat="server" Text="查询" Icon="Find">
                                                                            <Listeners>
                                                                                <Click Handler="gridPanel_listdata.reload();" />
                                                                            </Listeners>
                                                                        </ext:Button>
                                                                    </td>
                                                                    <td align="right">&nbsp;&nbsp;&nbsp;&nbsp;
                                                                    </td>
                                                                    <td align="left" width="50%">
                                                                        <ext:Button ID="extBtn_Clear" runat="server" Text="清空" Icon="BasketDelete">
                                                                            <Listeners>
                                                                                <Click Handler="searchForm.reset();" />
                                                                            </Listeners>
                                                                        </ext:Button>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </Content>
                                                    </ext:Panel>
                                                </Items>
                                            </ext:Container>
                                        </Items>
                                    </ext:Container>
                                </Items>
                            </ext:FieldSet>
                        </Content>
                    </ext:FormPanel>
                    <ext:GridPanel runat="server" ID="gridPanel_listdata" RowHeight="1" BodyStyle="border-width:1 0 0 0;" AutoScroll="true" TrackMouseOver="true" StripeRows="true">
                        <ColumnModel>
                            <Columns>
                                <ext:RowNumbererColumn Header="<center>序号</center>" Width="35" />
                                <ext:Column Header="收退单号" Width="120" DataIndex="CustomerReturnNo" />
                                <ext:Column Header="<center>收退库房</center>" Width="120" DataIndex="StoreRoomName" />
                                <ext:Column Header="<center>客户</center>" Width="140" DataIndex="CustomerName" />
                                <ext:Column Header="<center>创建人</center>" Width="80" DataIndex="InUserName" />
                                <ext:DateColumn Header="<center>创建时间</center>" Width="125" DataIndex="InDate" Format="Y-m-d H:i:s" />
                                <ext:Column Header="<center>审核状态</center>" Width="80" DataIndex="State">
                                    <Renderer Fn="StateRenderer" />
                                </ext:Column>
                                <ext:Column Header="备注" Width="150" DataIndex="Remark" />
                            </Columns>
                        </ColumnModel>
                        <Store>
                            <ext:Store runat="server" ID="Store1" OnRefreshData="MyData_Refresh">
                                <Reader>
                                    <ext:JsonReader IDProperty="CustomerReturnId">
                                        <Fields>
                                            <ext:RecordField Name="CustomerReturnId" Type="Int" />
                                            <ext:RecordField Name="CustomerReturnNo" />
                                            <ext:RecordField Name="StoreRoomId" Type="Int" />
                                            <ext:RecordField Name="StoreRoomName"  />
                                            <ext:RecordField Name="InUser" />
                                            <ext:RecordField Name="InUserName" />
                                            <ext:RecordField Name="InDate" Type="Date" />
                                            <ext:RecordField Name="CheckUser" />
                                            <ext:RecordField Name="CheckDate" />
                                            <ext:RecordField Name="State" Type="Int" />
                                            <ext:RecordField Name="CustomerId" Type="Int" />
                                            <ext:RecordField Name="CustomerName" />
                                            <ext:RecordField Name="Comment" />
                                            <ext:RecordField Name="Remark" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <SelectionModel>
                            <ext:RowSelectionModel runat="server" SingleSelect="true" />
                        </SelectionModel>
                        <BottomBar>
                            <ext:PagingToolbar runat="server" ID="PagingToolbar1" PageSize="20" DisplayInfo="true"
                                Height="25" DisplayMsg="显示{0} - {1},共{2}条" EmptyMsg="没有可显示的记录" StateID="Store1" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Content>
    </ext:Viewport>
    </form>
</body>
</html>
